import { api } from './request'

/**
 * 会员管理相关API接口
 */
export const memberApi = {
  /**
   * 获取会员列表
   * @param params 查询参数
   */
  getMemberList: (params: {
    page: number
    pageSize: number
    username?: string
    nickname?: string
    email?: string
    phone?: string
    status?: number
    levelId?: number
  }) => {
    return api.get('/member/list', params)
  },

  /**
   * 获取会员详情
   * @param id 会员ID
   */
  getMemberDetail: (id: number) => {
    return api.get(`/member/detail/${id}`)
  },

  /**
   * 添加会员
   * @param data 会员数据
   */
  addMember: (data: {
    username: string
    password: string
    nickname?: string
    avatar?: string
    email?: string
    phone?: string
    status: number
    levelId: number
  }) => {
    return api.post('/member/add', data)
  },

  /**
   * 编辑会员
   * @param data 会员数据
   */
  updateMember: (data: {
    id: number
    username: string
    nickname?: string
    avatar?: string
    email?: string
    phone?: string
    status: number
    levelId: number
  }) => {
    return api.put('/member/update', data)
  },

  /**
   * 删除会员
   * @param id 会员ID
   */
  deleteMember: (id: number) => {
    return api.delete(`/member/delete/${id}`)
  },

  /**
   * 重置会员密码
   * @param id 会员ID
   * @param password 新密码
   */
  resetPassword: (id: number, password: string) => {
    return api.put('/member/reset-password', { id, password })
  }
}